package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.KjtTradeState;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * Created by Huqin on 2020/8/12
 */
@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "kjt_payment")
public class KjtPaymentEntity {

    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(unique = true, columnDefinition = ("varchar(40) not null comment '主键uuid'"))
    private String id;

    @Column(unique = true, columnDefinition = ("varchar(32) not null comment '通知的唯一标识'"))
    private String notifyId;

    @Column(columnDefinition = ("varchar(32) not null comment '快捷通交易订单号'"))
    private String outerTradeNo;

    @Column(columnDefinition = ("varchar(32) not null comment '系统内部订单号'"))
    private String orderNo;

    @Column(columnDefinition = ("varchar(32) not null comment '交易状态'"))
    @Enumerated(EnumType.STRING)
    private KjtTradeState tradeStatus;

    @Column(columnDefinition = ("int(10) not null comment '交易金额'"))
    private Integer tradeAmount;

    @Column(columnDefinition = ("datetime not null comment '交易创建时间'"))
    private LocalDateTime gmtCreate;

    @Column(columnDefinition = ("datetime default null comment '交易支付时间'"))
    private LocalDateTime gmtPayment;

    @Column(columnDefinition = ("datetime default null comment '交易关闭时间'"))
    private LocalDateTime gmtClose;

    @Column(columnDefinition = ("varchar(128) default null comment '失败原因'"))
    private String failReason;

    @Column(columnDefinition = ("varchar(16) default null comment '失败编码'"))
    private String failCode;
}
